package com.zzyl.task;

import com.zzyl.mapper.ReservationMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

/**
 * 定时取消预约
 */
@Component
public class ScheduledTask {

    @Autowired
    private ReservationMapper reservationMapper;

    /**
     * 定时任务
     */
    @Scheduled(cron = "0 1,31 8-18 * * ?")
    public void executeTask() {
        //获取当前时间
        LocalDateTime time = LocalDateTime.now();
        //调用reservationMapper修改状态
        reservationMapper.updateReservationStatusByTime(time);

    }
}
